package com.diaohw.platform.common.exception;

import com.diaohw.platform.common.enums.CodeMsgEnum;
import com.diaohw.platform.common.obj.Result;
import lombok.Getter;


/**
 * @author 刁海文
 * @Remark 全局通用异常配置类
 * @since 2023/6/11 16:29
 */
@Getter
public class GlobalException extends RuntimeException {


    /**
     * 状态数据来源{@link CodeMsgEnum#status}
     */
    private final String status;
    /**
     * 消息提示 数据来源{@link CodeMsgEnum#describe}
     */
    private final String msg;


    public GlobalException(String msg) {
        super(msg);
        this.msg = msg;
        this.status = CodeMsgEnum.DATA.status;
    }

    public GlobalException(String status, String msg) {
        super(msg);
        this.msg = msg;
        this.status = status;
    }


    public Result<?> getResult() {
        return Result.fail(status, msg);
    }

}
